/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.designless.business.model;

import br.com.designless.business.entity.FutibaManagerEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author diogenes.feijo
 */
@Entity
@Table(name = "jogos")
@NamedQueries({
    @NamedQuery(name = "Jogos.findAll",
                query = "SELECT j FROM Jogos j"),
    @NamedQuery(name = "Jogos.findById",
                query = "SELECT j FROM Jogos j WHERE j.id = :id"),
    @NamedQuery(name = "Jogos.findByData",
                query = "SELECT j FROM Jogos j WHERE j.data = :data"),
    @NamedQuery(name = "Jogos.findByHistorico",
                query = "SELECT j FROM Jogos j WHERE j.historico = :historico")
})
public class Jogos implements FutibaManagerEntity {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;

    @Basic(optional = false)
    @Column(name = "DATA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date data;

    @Column(name = "HISTORICO")
    private String historico;

    @JoinTable(
        name = "participantes_jogo",
        joinColumns = {@JoinColumn(name = "ID_JOGO", referencedColumnName = "ID")},
        inverseJoinColumns = {@JoinColumn(name = "ID_USUARIO", referencedColumnName = "ID")}
    )
    @ManyToMany(fetch=FetchType.EAGER)
    private List<Usuarios> usuarios;

    @JoinColumn(name = "LOCAL", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Locais local;

    public Jogos() {
    }

    public Jogos(Integer id) {
        this.id = id;
    }

    public Jogos(Integer id, Date data) {
        this.id = id;
        this.data = data;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public String getHistorico() {
        return historico;
    }

    public void setHistorico(String historico) {
        this.historico = historico;
    }

    public List<Usuarios> getUsuarios() {
        return usuarios;
    }

    public void setUsuarios(List<Usuarios> usuarios) {
        this.usuarios = usuarios;
    }

    public Locais getLocal() {
        return local;
    }

    public void setLocal(Locais local) {
        this.local = local;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Jogos)) {
            return false;
        }
        Jogos other = (Jogos) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.designless.business.model.Jogos[id=" + id + "]";
    }

    public Serializable getPk() {
        return this.getId();
    }

}